package com.api.oa.mapper;

import com.api.oa.model.entity.YQAssessment;
import com.api.oa.model.vo.OaNoticeVo;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
@Mapper
public interface YQAssessmentMapper {

    @Insert("insert into  yq_assessment  (" +
        "sealOfCare," +
        "settlementCode," +
        "doctorSign," +
        "nurseSign," +
        "patientName," +
        "ssCard," +
        "identity," +
        "cdad," +
        "insEat," +
        "insShower," +
        "insGrooming," +
        "insDressing," +
        "insShit," +
        "insUrine," +
        "insToilet," +
        "insCharMove," +
        "insWalk," +
        "insUpStair," +
        "insTotal," +
        "insAgree," +
        "insSign," +
        "govEat," +
        "govShower," +
        "govDressing," +
        "govShit," +
        "govUrine," +
        "govToilet," +
        "govCharMove," +
        "govWalk," +
        "govUpStair," +
        "govGrooming," +
        "govTotal," +
        "govSign," +
        "idCard," +
        "userId," +
        "insUserId," +
        "requestOrder," +
        "createdAt," +
        "updatedAt" +
    ") " +
    "values " +
    "(" +
        "#{entity.sealOfCare}," +
        "#{entity.settlementCode}," +
        "#{entity.doctorSign}," +
        "#{entity.nurseSign}," +
        "#{entity.patientName}," +
        "#{entity.ssCard}," +
        "#{entity.identity}," +
        "#{entity.cdad}," +
        "#{entity.insEat}," +
        "#{entity.insShower}," +
        "#{entity.insGrooming}," +
        "#{entity.insDressing}," +
        "#{entity.insShit}," +
        "#{entity.insUrine}," +
        "#{entity.insToilet}," +
        "#{entity.insCharMove}," +
        "#{entity.insWalk}," +
        "#{entity.insUpStair}," +
        "#{entity.insTotal}," +
        "#{entity.insAgree}," +
        "#{entity.insSign}," +
        "#{entity.govEat}," +
        "#{entity.govShower}," +
        "#{entity.govDressing}," +
        "#{entity.govShit}," +
        "#{entity.govUrine}," +
        "#{entity.govToilet}," +
        "#{entity.govCharMove}," +
        "#{entity.govWalk}," +
        "#{entity.govUpStair}," +
        "#{entity.govGrooming}," +
        "#{entity.govTotal}," +
        "#{entity.govSign}," +
        "#{entity.idCard}," +
        "#{entity.userId}," +
        "#{entity.insUserId}," +
        "#{entity.requestOrder}," +
        "#{entity.createdAt}," +
        "#{entity.updatedAt}" +
    ")" )
    //@Options(useGeneratedKeys = true, keyProperty = "noticeId", keyColumn = "id")
    Integer insert(@Param("entity")YQAssessment entity);



    @Update("update  yq_assessment  set " +
        "sealOfCare = #{entity.sealOfCare}," +
        "settlementCode = #{entity.settlementCode}," +
        "doctorSign = #{entity.doctorSign}," +
        "nurseSign = #{entity.nurseSign}," +
        "patientName = #{entity.patientName}," +
        "ssCard = #{entity.ssCard}," +
        "identity = #{entity.identity}," +
        "cdad = #{entity.cdad}," +
//        "insEat = #{entity.insEat}," +
//        "insShower = #{entity.insShower}," +
//        "insGrooming = #{entity.insGrooming}," +
//        "insDressing = #{entity.insDressing}," +
//        "insShit = #{entity.insShit}," +
//        "insUrine = #{entity.insUrine}," +
//        "insToilet = #{entity.insToilet}," +
//        "insCharMove = #{entity.insCharMove}," +
//        "insWalk = #{entity.insWalk}," +
//        "insUpStair = #{entity.insUpStair}," +
//        "insTotal = #{entity.insTotal}," +
//        "insAgree = #{entity.insAgree}," +
//        "insSign = #{entity.insSign}," +
//        "govEat = #{entity.govEat}," +
//        "govShower = #{entity.govShower}," +
//        "govDressing = #{entity.govDressing}," +
//        "govShit = #{entity.govShit}," +
//        "govUrine = #{entity.govUrine}," +
//        "govToilet = #{entity.govToilet}," +
//        "govCharMove = #{entity.govCharMove}," +
//        "govWalk = #{entity.govWalk}," +
//        "govUpStair = #{entity.govUpStair}," +
//        "govGrooming = #{entity.govGrooming}," +
//        "govTotal = #{entity.govTotal}," +
//        "govSign = #{entity.govSign}," +
        "idCard = #{entity.idCard}," +
        "updatedAt = #{entity.updatedAt}" +
    " where  requestOrder = #{entity.requestOrder}")
    Integer update(@Param("entity")YQAssessment  entity);


    @Delete("delete from yq_assessment where idCard=#{id}")
    void delete(@Param("id")Long id);


    @Select("<script> select * from  yq_assessment  where 1=1 <if test='id!=null and id!=\"\"'>requestOrder = #{id}</if> </script>")
    List<YQAssessment> list(@Param("id")String pid);


    @Select("select * from  yq_assessment  where requestOrder = #{id} limit 1")
    YQAssessment findOne(@Param("id")String id);


    @Select("select * from  yq_assessment  where requestOrder = #{id} limit 1")
    YQAssessment findOneByOrder(@Param("id")String requestOrder);


    @Select("select * from  yq_assessment  where userId = #{id} and insUserId =#{insUserId}  limit 1")
    YQAssessment findOneByPatientAndIns(@Param("userId")Long userId,@Param("insUserId")Long InsUserId);


    @Update("update  yq_assessment  set " +
            "govEat = #{entity.govEat}," +
            "govShower = #{entity.govShower}," +
            "govDressing = #{entity.govDressing}," +
            "govShit = #{entity.govShit}," +
            "govUrine = #{entity.govUrine}," +
            "govToilet = #{entity.govToilet}," +
            "govCharMove = #{entity.govCharMove}," +
            "govWalk = #{entity.govWalk}," +
            "govUpStair = #{entity.govUpStair}," +
            "govGrooming = #{entity.govGrooming}," +
            "govTotal = #{entity.govTotal}," +
            "updatedAt = #{entity.updatedAt}" +
            " where requestOrder = #{entity.requestOrder}")
    Integer updateByGov(@Param("entity") YQAssessment entity);

    @Update("update  yq_assessment  set " +
            "insEat = #{entity.insEat}," +
            "insShower = #{entity.insShower}," +
            "insGrooming = #{entity.insGrooming}," +
            "insDressing = #{entity.insDressing}," +
            "insShit = #{entity.insShit}," +
            "insUrine = #{entity.insUrine}," +
            "insToilet = #{entity.insToilet}," +
            "insCharMove = #{entity.insCharMove}," +
            "insWalk = #{entity.insWalk}," +
            "insUpStair = #{entity.insUpStair}," +
            "insTotal = #{entity.insTotal}" +
            " where requestOrder = #{entity.requestOrder}")
    Integer updateByIns(@Param("entity") YQAssessment entity);
}

